﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Lexicon;

namespace Parser
{
    public class Parser
    {
        public Lexicon.Lexicon Tokens { get; set; }
        public List<object> Lists { get; set; }
        public ObservableCollection<object> Collection { get; set; }

        public Parser(ObservableCollection<object> collection)
        {
            Lexicon.Lexicon Tokens = Lexicon.Lexicon.Instance;
            Lists = new List<object>();
            Collection = collection;
        }

        public bool Contains(Object element)
        {
            foreach (Token item in this.Tokens.Expression.StartOfExpressionCollection)
            {
                if (element.ToString() == item.Value)
                    return true;
            }

            return false;
        }

        public bool ContainsCommandUnitary(Object element)
        {
            foreach (Token item in this.Tokens.Expression.CommandCollection.CommandUnitary)
            {
                if (element.ToString() == item.Value)
                    return true;
            }

            return false;
        }

        public bool ContainsCommandBinary(Object element)
        {
            foreach (Token item in this.Tokens.Expression.CommandCollection.CommandBinary)
            {
                if (element.ToString() == item.Value)
                    return true;
            }

            return false;
        }

        public void Execute(object o)
        {
            if (ContainsCommandBinary(o))
                ExecuteBinary(o);
            if (ContainsCommandUnitary(o))
                ExecuteUnitray(o);
            else
                throw new NotImplementedException();
        }

        private void ExecuteUnitray(object o)
        {
            throw new NotImplementedException();
        }

        private void ExecuteBinary(object o)
        {
            throw new NotImplementedException();
        }

        //public List<object> ExecuteUnitary(string command, object o)
        //{
        //   this.Tokens.Expression.CommandCollection.CommandUnitary.
        //}
    }
}
